“HDF5HighLevel Examples”

Information

This file demonstrates some of the functionality of HDF5HighLevel examples. To see all available functions, check “UtilityThatListsWrappedFunctions.nb”.

Prepared 15 July 2011 by Scot Martin for Windows 7, 64-bit, Mathematica version 8.0.1.

Email: scot_martin@harvard.edu.

Implementation in Mathematica

SetDirectory@NotebookDirectory[];
Needs["HDF5HighLevel`"]

subfolderWithExamples="HDF5HighLevel ExampleFiles"

GroupsAndDataSetsInformation

?NamesAndTypesAtOneNode

With[

{filename=FileNameJoin[{Directory[],subfolderWithExamples,"h5ex_g_iterate.h5"}]},

H5FExtendOpen[
{fileID=H5Fopen[filename,H5FuACCuRDONLY,H5PuDEFAULT]},

NamesAndTypesAtOneNode[fileID]
]

]

?NamesAndTypes

With[
{filename=FileNameJoin[{Directory[],subfolderWithExamples,"h5ex_g_iterate.h5"}]},
NamesAndTypes[filename]
]

With[
{filename=FileNameJoin[{Directory[],subfolderWithExamples,"h5ex_g_intermediate.h5"}]},
NamesAndTypes[filename]
]

DataSetDimensions

?DataSetDimensions

With[
{
file=FileNameJoin[{Directory[],subfolderWithExamples,"h5ex_d_fillval.h5"}],
dataSet="DS1"
},
DataSetDimensions[file,dataSet]
]

DataSetDataTypeClass

?DataSetDataTypeClass

With[
{
file=FileNameJoin[{Directory[],subfolderWithExamples,"h5ex_d_fillval.h5"}],
dataSet="DS1"
},
DataSetDataTypeClass[file,dataSet]
]

ReadHyperSlab

?ReadHyperSlab

read all data

With[
{
file=FileNameJoin[{Directory[],subfolderWithExamples,"h5ex_d_fillval.h5"}],
dataSet="DS1"
},
ReadHyperSlab[file,dataSet,{1,1},{6,10}]
]

%//TableForm

read subset of data

With[
{
file=FileNameJoin[{Directory[],subfolderWithExamples,"h5ex_d_fillval.h5"}],
dataSet="DS1"
},
ReadHyperSlab[file,dataSet,{2,2},{3,2}]
]

%//TableForm

CompoundDataTypes

?CompoundDataType`Information

With[
{
file=FileNameJoin[{Directory[],subfolderWithExamples,"h5ex_t_cmpd.h5"}],
dataSet="DS1"
},
CompoundDataType`Information[file,dataSet]
]

?CompoundDataType`Values

?CompoundDataType`RawData

?CompoundDataType`Transform

With[
{
file=FileNameJoin[{Directory[],subfolderWithExamples,"h5ex_t_cmpd.h5"}],
dataSet="DS1"
},
CompoundDataType`Values[file,dataSet]
]

For VariableLengthString, additional programming would be required.

Show result after filtering out VariableLengthString.

%[[{1,3,4}]]//TableForm

manual demonstration of how to get string value from VariableLengthString (advanced topic)

http://msdn.microsoft.com/en-us/library/system.bitconverter.aspx
http://msdn.microsoft.com/en-US/library/system.intptr_members(v=VS.80).aspx

LoadedNETObjects[]

BeginNETBlock[]

data=

With[
{
file=FileNameJoin[{Directory[],subfolderWithExamples,"h5ex_t_cmpd.h5"}],
dataSet="DS1"
},
CompoundDataType`RawData[file,dataSet]
]

pointer1=OptionValue[data,"Data"][[2,1]]

pointer1NETObject=MakeNETObject[pointer1,"System.Byte[]"]

LoadNETType["System.BitConverter"]

memoryLocationPointer1=BitConverter`ToInt64[pointer1NETObject,0]

intPtr1=NETNew["System.IntPtr",memoryLocationPointer1]

(* load to allow names to be extracted as Strings from IntPtr return *)
LoadNETType["System.Runtime.InteropServices.Marshal"]

Marshal`PtrToStringAnsi[intPtr1]

EndNETBlock[]

LoadedNETObjects[]

Attributes

?ReadAttributes

With[
{
file=FileNameJoin[{Directory[],subfolderWithExamples,"h5ex_t_intatt.h5"}],
dataSet="DS1"
},
ReadAttributes[file,dataSet]
]

With[
{
file=FileNameJoin[{Directory[],subfolderWithExamples,"h5ex_t_floatatt.h5"}],
dataSet="DS1"
},
ReadAttributes[file,dataSet]
]